document.querySelector('#for').onclick = function() {
    if(document.querySelector('#newtask input').value.length == 0){
        alert("打上你要干哈滴事情！");
    }else{
        document.querySelector('#tasks').innerHTML+= `
        <div class="task">
            <span id="taskname">
                ${document.querySelector('#newtask input').value}
            </span>
            <button class="delete">
                <i class="far fa-trash-alt">delete</i>
            </button>
        </div>
    `;

        var clist=document.querySelectorAll(".delete");
        for(var i=0 ; i<clist.length ; i++){
            clist[i].onclick=function(){
                this.parentNode.remove();
            }
        }
    }
}